#include <stdio.h>

int main(int argc, char *argv[])
{
    char buf[1024*4] = {0};
    int len = 0;
    FILE *fp = fopen("test.txt", "r");

    if (NULL == fp) {
        fprintf(stderr, "fopen failed\n");
        return -1;
    }

    len = fread(buf, 1, sizeof(buf), fp);
//    len = fread(buf, sizeof(buf), 1, fp);   //这个会返回0，因为未读满sizeof(buf)字节


    printf("read (%d) bytes: %s\n", len, buf);

    int i = 0;
    for ( ; i<len; ++i) {
        printf("%c", buf[i]);
    }
    printf("\n");
    fclose(fp);

    return 0;
}
